<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .lll {
            color: red;
            font-family: Georgia, serif;
        }

        input {
            width: 100px;
            height: 20px;
            outline: none;
            border: 1px solid #3954f0;
            font-family: Arial, sans-serif;
            transition: width 0.4s ease, height 0.4s ease, border 0.4s ease;
        }

        input:hover {
            color: red;
            width: 200px;
            height: 30px;
        }
    </style>
</head>

<body>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <div id="app">
        <div class="lll">哈基{{last}}</div>
        <input type="text" v-model="message" placeholder="请输入内容">
    </div>

    <div>
        <p>哈基</p>
        <label>
            <input type="text" placeholder="请输入内容" class="hj">
        </label>

    </div>
    <script>  
             const input=document.querySelector('.hj')
             input.addEventListener('input',function(){
                const p = document.querySelector('p')
                p.textContent=  `哈基${input.value.slice(-1)}`
             })
    </script>



    <script>
        const { createApp } = Vue
        createApp({
            data() {
                return {
                    message: ''
                }
            },
            computed: {
                // 获取输入字符串的最后一个字符
                last() {
                    if (this.message.length === 0) {
                        return ''; // 输入为空时返回空字符串
                    }
                    return this.message.slice(-1);
                }
            }
        }).mount('#app')
    </script>
</body>

</html>